package tmall.framework.eobj;

import lombok.Data;

import java.math.BigInteger;
import java.sql.Timestamp;

@Data
public class SegmentEobj {
    public static final String DEFAULT_STEP = "1";
    private String name;
    private long maxId;
    private int step;
    private int minStep;
    private String description;
    private Timestamp updateTime;
    private long value;

    public SegmentEobj(String key, long maxId, int step, String description) {
        this.name = key;
        this.maxId = maxId;
        this.step = step;
        this.minStep = step;
        this.description = description;
        this.value = maxId;
    }

    public SegmentEobj() {
    }

    public synchronized long getNextId() {
        return value++;
    }

    public long getIdle() {
        return maxId - value;
    }
}
